package com.ershi.spring.tx.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;

/**
 * @author 二十
 * @since 2021/11/17 8:36 上午
 */
@Configuration
@ComponentScan("com.ershi.spring.tx")
/**
 * 给容器中导入了一个组件：TransactionManagementConfigurationSelector
 */
@EnableTransactionManagement
public class SpringConfig {
	//数据源 + JDBCTemplate
	@Bean
	public DataSource dataSource(){

		return null;
	}

	@Bean
	public PlatformTransactionManager transactionManager(){
		return new DataSourceTransactionManager(dataSource());
	}
}
